<template>
  <div>
    <div class="center-top">
      <div class="user-img">
        <img src="@/assets/mzdl.png" alt="" />
      </div>
      <span v-if="userName">{{ userName}} </span>
      <span v-else class="user-info" @click="toLogin">立即登录</span>
    </div>
    <div class="order">
      <div class="order-left">
        <div>0张</div>
        <div>卖座券</div>
      </div>
      <div class="order-right">
        <div>¥0</div>
        <div>余额</div>
      </div>
    </div>
    <div>
      <van-cell
        v-for="item in cellList"
        :key="item.id"
        :title="item.title"
        is-link
        :to="item.url">
        <template #icon>
          <van-icon
            :name="item.icon"
            class="cell-icon"
            :color="item.color"/>
        </template>
      </van-cell>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userName: localStorage.getItem('userName'),
      cellList: [
        {
          id: "order",
          title: "电影订单",
          icon: "coupon",
          color: "#ffc82f",
          url: "/center/order",
        },
        {
          id: "discounts",
          title: "组合红包",
          icon: "balance-o",
          color: "#baa27a",
          url: "/center/red-packet",
        },
        {
          id: "help",
          title: "帮助与客服",
          icon: "service-o",
          color: "#95b7d0",
          url: "/center/help",
        },
        {
          id: "setting",
          title: "设置",
          icon: "setting-o",
          color: "#bed060",
          url: "/center/setting",
        },
      ],
    };
  },
  methods: {
    toLogin(){
      this.$router.push('/login')
    }
  }
};
</script>

<style scoped>
.center-top {
  text-align: left;
  height: 100px;
  margin-top: -44px;
  padding-top: 100px;
  padding-left: 22px;
  background: url("@/assets/bj.png");
  background-size: cover;
  color: #fff;
}
.user-img {
  display: inline-block;
  width: 63px;
  height: 63px;
  border-radius: 35px;
  margin-right: 20px;
  border: 2px solid #fff;
  overflow: hidden;
  vertical-align: middle;
  background: #fff;
}
.user-info {
  vertical-align: middle;
}
.user-img img {
  width: 63px;
}
.order {
  text-align: center;
  display: flex;
  height: 79px;
  align-items: center;
}
.order div {
  width: 100%;
}
.order div :first-child {
  color: #191a1b;
  font-size: 17px;
}
.order div :nth-child(2) {
  font-size: 13px;
  color: #797d82;
  line-height: 13px;
}
.cell-icon {
  font-size: 16px;
  line-height: inherit;
  padding-right: 8px;
}
</style>